package com.vf.admin.client.controller.pay.sandpay.util;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

/**
 * <p>Title : 初始化杉德密钥监听器</p>
 * <p>Description : </p>
 * <p>DevelopTools : IDEA</p>
 * <p>DevelopSystem : Windows10</p>
 *
 * @Author : NemoMeng
 * @Date 2023/7/6 15:09
 */
@Component
public class ContextLoadListener implements ApplicationListener<ContextRefreshedEvent> {

    private static final Logger logger = LoggerFactory.getLogger(ContextLoadListener.class);


    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        logger.info("加载证书...");
        // 加载证书
        try {
            //加载配置文件
            SDKConfig.getConfig().loadPropertiesFromSrc();
            //加载证书
            CertUtil.init(SDKConfig.getConfig().getSandCertPath(), SDKConfig.getConfig().getSignCertPath(), SDKConfig.getConfig().getSignCertPwd());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
